/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author SONY
 */
@Entity
@Table(name = "Member")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "MemberCustomer.findAll", query = "SELECT m FROM MemberCustomer m"),
    @NamedQuery(name = "MemberCustomer.findByMemberID", query = "SELECT m FROM MemberCustomer m WHERE m.memberID = :memberID"),
    @NamedQuery(name = "MemberCustomer.findByFirstName", query = "SELECT m FROM MemberCustomer m WHERE m.firstName = :firstName"),
    @NamedQuery(name = "MemberCustomer.findByLastName", query = "SELECT m FROM MemberCustomer m WHERE m.lastName = :lastName"),
    @NamedQuery(name = "MemberCustomer.findByAddress", query = "SELECT m FROM MemberCustomer m WHERE m.address = :address"),
    @NamedQuery(name = "MemberCustomer.findByPhone", query = "SELECT m FROM MemberCustomer m WHERE m.phone = :phone"),
    @NamedQuery(name = "MemberCustomer.findByGender", query = "SELECT m FROM MemberCustomer m WHERE m.gender = :gender")})
public class MemberCustomer implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "MemberID")
    private Integer memberID;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "FirstName")
    private String firstName;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "LastName")
    private String lastName;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 150)
    @Column(name = "Address")
    private String address;
    // @Pattern(regexp="^\\(?(\\d{3})\\)?[- ]?(\\d{3})[- ]?(\\d{4})$", message="Invalid phone/fax format, should be as xxx-xxx-xxxx")//if the field contains phone or fax number consider using this annotation to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 25)
    @Column(name = "Phone")
    private String phone;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 1)
    @Column(name = "Gender")
    private String gender;
    @OneToOne(mappedBy = "memberID")
    private UserLogin userLogin;
    @OneToMany(mappedBy = "memberID")
    private Collection<SaleOrder> saleOrderCollection;

    public MemberCustomer() {
    }

    public MemberCustomer(Integer memberID) {
        this.memberID = memberID;
    }

    public MemberCustomer(Integer memberID, String firstName, String lastName, String address, String phone, String gender) {
        this.memberID = memberID;
        this.firstName = firstName;
        this.lastName = lastName;
        this.address = address;
        this.phone = phone;
        this.gender = gender;
    }

    public Integer getMemberID() {
        return memberID;
    }

    public void setMemberID(Integer memberID) {
        this.memberID = memberID;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public UserLogin getUserLogin() {
        return userLogin;
    }

    public void setUserLogin(UserLogin userLogin) {
        this.userLogin = userLogin;
    }

    @XmlTransient
    public Collection<SaleOrder> getSaleOrderCollection() {
        return saleOrderCollection;
    }

    public void setSaleOrderCollection(Collection<SaleOrder> saleOrderCollection) {
        this.saleOrderCollection = saleOrderCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (memberID != null ? memberID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof MemberCustomer)) {
            return false;
        }
        MemberCustomer other = (MemberCustomer) object;
        if ((this.memberID == null && other.memberID != null) || (this.memberID != null && !this.memberID.equals(other.memberID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.MemberCustomer[ memberID=" + memberID + " ]";
    }
    
}
